package com.winner.crmsoftware.main;

import com.winner.crmsoftware.addcustomer.AddCustomerActivity;
import com.winner.crmsoftware.customers.ListCustomerActivity;
import com.winner.crmsoftware.employee.EmployeeInfomationActivity;
import com.winner.crmsoftware.employee.SaleLocationActivity;
import com.winner.crmsoftware.ultil.PreferentUltils;
import com.winner.crmsoftware.updatelocation.UpdateLocationActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainProgramActivity extends Activity {

	Button btn_location;
	Button btn_customers;
	Button btn_sale_location;

	Context context;

	SharedPreferences pref;
	Editor editor;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_program);
		context = this;

		pref = getApplicationContext().getSharedPreferences(PreferentUltils.EMPLOYEE_INFO, MODE_PRIVATE);
		editor = pref.edit();

		if (pref.getString(PreferentUltils.ID_EMPLOYEE, null) == null) {
			Intent intent = new Intent(this, EmployeeInfomationActivity.class);
			startActivity(intent);
			finish();
		}
		
		

		btn_customers = (Button) findViewById(R.id.btn_customer);
		btn_location = (Button) findViewById(R.id.btn_locaton);
		btn_sale_location= (Button) findViewById(R.id.btn_sale_location);

		btn_customers.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(context, ListCustomerActivity.class);
				startActivity(intent);
				finish();
			}
		});

		btn_location.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(context, UpdateLocationActivity.class);
				startActivity(intent);
				finish();
			}
		});
		
		
		btn_sale_location.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(context, SaleLocationActivity.class);
				startActivity(intent);
			}
		});

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

}
